package xyz.erupt.flow.data.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import xyz.erupt.flow.bean.entity.OaWorkFlowDefinition;
import xyz.erupt.flow.bean.entity.OaWorkFlowGroup;
import xyz.erupt.flow.data.dto.DTO_OaWorkFlowGroup;
import xyz.erupt.flow.data.vo.VO_OaWorkFlowDefinition;
import xyz.erupt.flow.data.vo.VO_OaWorkFlowGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * @author PP
 * @version 1.0
 * @project flow
 * @description
 * @date 2025/1/8 11:06:54
 */
@Mapper
public interface OaWorkFlowGroupMapper {
    OaWorkFlowGroupMapper INSTANCE = Mappers.getMapper(OaWorkFlowGroupMapper.class);

    DTO_OaWorkFlowGroup toDto(OaWorkFlowGroup oaWorkFlowGroup);

    OaWorkFlowGroup dtoTo(DTO_OaWorkFlowGroup dto);

    @Mappings({
            @Mapping(target = "workFlowDefinitions",expression = "java(toList(oaWorkFlowGroup.getWorkFlowDefinitions()))")
    })
    VO_OaWorkFlowGroup toVo(OaWorkFlowGroup oaWorkFlowGroup);

    List<VO_OaWorkFlowGroup> toVo(List<OaWorkFlowGroup> oaWorkFlowGroups);

    default List<VO_OaWorkFlowDefinition> toList(List<OaWorkFlowDefinition> oaWorkFlowDefinitions){
        List<VO_OaWorkFlowDefinition> vo = OaWorkFlowDefinitionMapper.INSTANCE.toVo(oaWorkFlowDefinitions);
        return vo;
    }
}
